package com.altekis.kanbankaze.shared;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Queries;
import javax.jdo.annotations.Query;

/**
 * Represents an UserAccount
 * 
 * @author lordkhizir
 * 
 */
@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@Queries({ @Query(name = "findNewer", value = "select from Task o where modificationDate > :minDate") })
public class UserAccount implements Serializable, Comparable<UserAccount> {

	@Persistent
	private String avatarUrl;
	@Persistent
	private Date createDate;
	@Persistent
	private String channelId;
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@PrimaryKey
	private String id;
	@Persistent
	private String login;
	@Persistent
	private Date modificationDate;
	@Persistent
	private String name;

	@Override
	public int compareTo(UserAccount o) {
		return this.getId().compareTo(o.getId());
	}

	@Override
	public boolean equals(Object o) {
		boolean ret = false;
		if (o instanceof UserAccount) {
			UserAccount t = (UserAccount) o;
			ret = this.getId().equals(t.getId());
		}
		return ret;
	}

	/**
	 * @return the avatarUrl
	 */
	public String getAvatarUrl() {
		if (avatarUrl == null) {
			avatarUrl = "http://mail.google.com/mail/c/u/0/photos/public/AIbEiAIAAABDCPWcvpHT6_ncUCILdmNhcmRfcGhvdG8qKDBmMzZhMDM3NzhlYTAyN2ZlMmI4Njc0MjExMThjYjkyZTc5OWNlNGQwAZNMW9KFS3ocw98Yp-fZf6fgz2rf?sz=32";
		}
		return avatarUrl;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public String getChannelId() {
		return channelId;
	}

	public String getId() {
		return id;
	}

	public String getLogin() {
		return login;
	}

	public Date getModificationDate() {
		return modificationDate;
	}

	public String getName() {
		return name;
	}

	/**
	 * @param avatarUrl
	 *            the avatarUrl to set
	 */
	public void setAvatarUrl(String avatarUrl) {
		this.avatarUrl = avatarUrl;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public void setChannelId(String channelId) {
		this.channelId = channelId;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public void setModificationDate(Date modificationDate) {
		this.modificationDate = modificationDate;
	}

	public void setName(String name) {
		this.name = name;
	}
}
